#pragma once
#include "aimp2_sdk.h"
#include "DataConversion.h"
#include <vcclr.h>

namespace dotNetInteropPlugin {
	namespace PluginDev {
		using namespace System;
		using namespace System::Runtime::InteropServices;

	public ref class MAIMPFileInfoDynamicReadOnly: public MarshalByRefObject, public IMAIMPFileInfoReadOnly
	{
	internal:
		MAIMPFileInfoDynamicReadOnly(AIMP2FileInfo* finf)
		{
			inFinf = finf;
		}
	private:
		AIMP2FileInfo* inFinf;
		String^ inAlbum;
		String^ inArtist;
		String^ inDate;
		String^ inFileName;
		String^ inGenre;
		String^ inTitle;

	public:
		property virtual Boolean IsActive
		{
			Boolean get()
			{
				return inFinf->nActive != 0;
			}
		}
		property virtual UInt32 BitRate
		{
			UInt32 get()
			{
				return inFinf->nBitRate;
			}
		}
		property virtual UInt32 ChanelNumber
		{
			UInt32 get()
			{
				return inFinf->nChannels;
			}
		}
		property virtual TimeSpan Duration
		{
			TimeSpan get()
			{
				return TimeSpan::FromSeconds(inFinf->nDuration);
			}
		}
		property virtual UInt64 FileSize
		{
			UInt64 get()
			{
				return inFinf->nFileSize;
			}
		}
		property virtual UInt32 Rating
		{
			UInt32 get()
			{
				return inFinf->nRating;
			}
		}
		property virtual UInt32 SampleRate
		{
			UInt32 get()
			{
				return inFinf->nSampleRate;
			}
		}
		property virtual UInt32 TrackID
		{
			UInt32 get()
			{
				return inFinf->nTrackID;
			}
		}

		property virtual String^ Album
		{
			String^ get()
			{
				if (inAlbum == nullptr)
					inAlbum = gcnew String(inFinf->sAlbum);
				return inAlbum;
			}
		}
		property virtual String^ Artist
		{
			String^ get()
			{
				if (inArtist == nullptr)
					inArtist = gcnew String(inFinf->sArtist);
				return inArtist;
			}
		}
		property virtual String^ Date
		{
			String^ get()
			{
				if (inDate == nullptr)
					inDate = gcnew String(inFinf->sDate);
				return inDate;
			}
		}
		property virtual String^ FileName
		{
			String^ get()
			{
				if (inFileName == nullptr)
					inFileName = gcnew String(inFinf->sFileName);
				return inFileName;
			}
		}
		property virtual String^ Genre
		{
			String^ get()
			{
				if (inGenre == nullptr)
					inGenre = gcnew String(inFinf->sGenre);
				return inGenre;
			}
		}
		property virtual String^ Title
		{
			String^ get()
			{
				if (inTitle == nullptr)
					inTitle = gcnew String(inFinf->sTitle);
				return inTitle;
			}
		}
	};
	
}
}